package cn.terminus.data.customer.contractrentincrementalclause.impl;

import cn.terminus.common.customer.bean.contractrentincrementalclause.dto.*;
import cn.terminus.data.customer.contractrentincrementalclause.dao.ContractRentIncrementalClauseDao;
import cn.terminus.data.customer.contractrentincrementalclause.mapper.ContractRentIncrementalClauseMapper;
import cn.terminus.result.common.page.TerminusPageAble;
import cn.terminus.result.common.page.TerminusPageInfo;
import cn.terminus.result.common.util.BeanCopyUtils;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * 合同递增条款(ContractRentIncrementalClause)表服务实现类
 *
 * @author makejava
 * @since 2021-07-21 11:16:27
 */
@Repository
public class ContractRentIncrementalClauseDaoImpl implements ContractRentIncrementalClauseDao {
    @Resource
    private ContractRentIncrementalClauseMapper contractRentIncrementalClauseMapper;

    @Override
    public Integer add(ContractRentIncrementalClauseNewDto dto) {
        return contractRentIncrementalClauseMapper.add(dto);
    }

    @Override
    public Integer update(ContractRentIncrementalClauseEditDto dto) {
        return contractRentIncrementalClauseMapper.update(dto);
    }

    @Override
    public List<ContractRentIncrementalClauseResultDto> gets(ContractRentIncrementalClauseGetsDto dto) {
        return contractRentIncrementalClauseMapper.gets(dto);
    }

    @Override
    public List<ContractRentIncrementalClauseResultDto> query(ContractRentIncrementalClauseQueryDto dto) {
        return contractRentIncrementalClauseMapper.query(dto);
    }

    @Override
    public Integer delete(ContractRentIncrementalClauseDeleteDto dto) {
        return contractRentIncrementalClauseMapper.delete(dto);
    }

    @Override
    public TerminusPageAble<ContractRentIncrementalClauseResultDto> page(ContractRentIncrementalClauseQueryDto dto, TerminusPageInfo page) {
        PageHelper.startPage(page.getCurrentPage(), page.getPageSize());
        Page<ContractRentIncrementalClauseResultDto> result = (Page<ContractRentIncrementalClauseResultDto>) contractRentIncrementalClauseMapper.query(dto);
        return new TerminusPageAble<>(BeanCopyUtils.copy(result.getResult(), ContractRentIncrementalClauseResultDto.class), page, result.getTotal());
    }

    @Override
    public Integer insertBatch(List<ContractRentIncrementalClauseNewDto> incrementalClauseNewDtos) {
        return contractRentIncrementalClauseMapper.insertBatch(incrementalClauseNewDtos);
    }

    @Override
    public Integer deleteWithContractId(Long contractId) {
        return contractRentIncrementalClauseMapper.deleteWithContractId(contractId);
    }
}
